package com.example.demo;

import com.example.demo.entity.AnotherComponent;
import com.example.demo.entity.JdbcConfiguration;
import com.example.demo.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@SpringBootApplication
@RestController
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@GetMapping("/hello")
	public String hello(){
		return "If you look the message,that server is ok.";
	}

	@Autowired
	private Person p;

	@GetMapping("/p")
	public Person person(){
		System.out.println("this is a normal message.");
		System.out.println("this is in featureC/活动1 branch add message.");
		System.out.println("add one tag from release branch.");
		System.out.println("fixed bug AAA.");
		System.out.println(p);
		return p;
	}

	@Autowired
	private DataSource dataSource;

	@Autowired
	private JdbcConfiguration jdbcConfiguration;

	@GetMapping("/j")
	public DataSource jdbcConfiguration(){
		System.out.println(dataSource);
		System.out.println(jdbcConfiguration);
		return dataSource;
	}

	@Autowired
	private AnotherComponent anotherComponent;

	@GetMapping("/a")
	public AnotherComponent anotherComponent(){
		System.out.println(anotherComponent);
		return anotherComponent;
	}
}
